package com.gl.mapper;

import com.gl.pojo.entity.Metrics;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Mapper
public interface MetricsMapper {

    @Select("select * from metrics where date = #{localDate}")
    Metrics getMetrics(LocalDate localDate);

    @Select("select * from metrics where date = #{localDate}")
    Metrics getMetricsByDate(LocalDate localDate);

    void update(Metrics metrics);

    void insert(LocalDate localDate);

    @Update("update metrics set new_users_today = new_users_today + #{increment} WHERE date = #{localDate}")
    int incrementNewUsersToday(LocalDate localDate, int increment);

    @Update("update metrics set online = online + #{increment} WHERE date = #{localDate}")
    int incrementOnline(LocalDate localDate, int increment);
}
